package com.vhall.component.framework.core.loader;

import java.util.List;

/**
 * 外部插件配置
 *
 * @author xiaoliang.wang@vhall.com
 * <p>
 * 示例配置
 * extension:
 * binders:
 * - application: spring-cloud-gateway-plugin-home
 * plugins:
 * - com.vhall.component.framework.plugin.general.handlers.cors.CorsHandler
 */
public class ExtensionBinder {

    private List<ExtensionProperties> binders;

    public void setBinders(List<ExtensionProperties> binders) {
        this.binders = binders;
    }

    /**
     * 重新构建应用插件列表，替换对应的引用
     *
     * @param extensions 自定义插件列表
     * @return 绑定
     */
    public void rebuild(List<CustomerExtension> extensions) {
        binders.forEach(binder -> binder.replacePlugin(extensions));
    }

}
